<template>
  <el-container class="manger-container">
    <el-header>
      <div>
        <img src="../assets/heima.png" alt="" />
        <span>择校宝--管理员系统</span>
      </div>
      <el-button type="info" @click="layout">退出</el-button>
    </el-header>
    <el-container>
      <el-aside :width="isCollapse ? '64px' : '200px'">
        <div class="toggle-button" @click="toggleCollapse">|||</div>
        <!-- 侧边栏菜单区域 -->
        <el-menu
          background-color="#333744"
          text-color="#fff"
          active-text-color="#409eff"
          :unique-opened="true"
          :collapse="isCollapse"
          :collapse-transition="false"
          :router="true"
        >
          <!-- 一级菜单 -->
          <el-submenu
            :index="item.id + ''"
            v-for="item in menuList"
            :key="item.id"
          >
            <!-- 一级菜单的模板区域 -->
            <template slot="title">
              <i :class="item.icon"></i>
              <span class="icon">{{ item.action }}</span>
            </template>
            <!-- 二级菜单 -->
            <el-menu-item v-for="value in item.children" :key="value.id" :index="value.path">
              <template slot="title">
                <i :class='value.icon '></i>
                <span class="icon">{{ value.action }}</span>
              </template>
            </el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-main><router-view></router-view></el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      isCollapse: false,
      menuList: [
        {
          id: 1,
          action: '增加',
          icon:'el-icon-edit',
          children: [
            {
              id: 2,
              path: '/manger/insertschool',
              action: '增加学校',
              icon:'el-icon-edit'
            },
            {
              id: 3,
              path: '/manger/insertprofession',
              action: '增加学校专业',
              icon:'el-icon-edit'
            }
          ]
        },
        {
          id: 4,
          action: '修改',
          icon:'el-icon-setting',
          children: [
            {
              id: 5,
              path: '/manger/updateschool',
              action: '修改学校',
              icon:'el-icon-setting'
            },
            {
              id: 6,
              path: '/manger/updateprofession',
              action: '修改学校专业',
              icon:'el-icon-setting'
            }
          ]
        },
        {
          id: 7,
          action: '删除',
          icon:'el-icon-delete',
          children: [
            {
              id: 8,
              path: '/manger/deleteschool',
              action: '删除学校',
              icon:'el-icon-delete'
            },
            {
              id: 9,
              path: '/manger/deleteprofession',
              action: '删除学校专业',
              icon:'el-icon-delete'
            }
          ]
        }
      ]
    }
  },
  methods: {
    toggleCollapse() {
      this.isCollapse = !this.isCollapse
    },
    layout () {
      this.$router.push('/login')
    }
  }
}
</script>

<style lang="less" scoped>
* {
  padding: 0;
  margin: 0;
}
.manger-container {
  height: 100%;
}
.el-header {
  background-color: #373d41;
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  align-items: center;
  color: #fff;
  font-size: 20px;
  > div {
    display: flex;
    align-items: center;
  }
  span {
    margin-left: 15px;
  }
}
.el-aside {
  background-color: #333744;
  .el-menu {
    border-right: none;
  }
}
.el-main {
  background-color: #eaedf1;
}
.icon {
  margin-left: 5px;
}
.toggle-button {
  background-color: #4a5064;
  color: #fff;
  font-size: 10px;
  line-height: 24px;
  text-align: center;
  letter-spacing: 0.2em;
  cursor: pointer;
}
</style>
